import request from '@/utils/request';

// 获取列表
export function getCategoryList(data) {
  return request({
    url: process.env.VUE_APP_BUS_SERVICE_NAME + 'api/ottVehicleBrand/getListByPage',
    method: 'post',
    data: data
  });
}

// 创建或者编辑
export function saveCategory(data) {
  let url = process.env.VUE_APP_BUS_SERVICE_NAME + 'api/ottVehicleBrand/create';
  if (data.objectId || data.objectId == 0) {
    url = process.env.VUE_APP_BUS_SERVICE_NAME + 'api/ottVehicleBrand/update';
  }
  return request({
    url: url,
    method: 'post',
    data: data
  });
}

// 删除选中数据
export function deleteSelectedCategory(ids) {
  return request({
    url: process.env.VUE_APP_BUS_SERVICE_NAME + 'api/ottVehicleBrand/deleteByList',
    method: 'post',
    data: {
      keyValues: ids
    }
  });
}

// 获取列表
export function getCompanyList(data) {
  return request({
    url: process.env.VUE_APP_BUS_SERVICE_NAME + 'api/ottTransportComp/getListByPage',
    method: 'post',
    data: data
  });
}

// 创建或者编辑
export function saveCompany(data) {
  let url = process.env.VUE_APP_BUS_SERVICE_NAME + 'api/ottTransportComp/create';
  if (data.objectId || data.objectId == 0) {
    url = process.env.VUE_APP_BUS_SERVICE_NAME + 'api/ottTransportComp/update';
  }
  return request({
    url: url,
    method: 'post',
    data: data
  });
}

// 删除选中数据
export function deleteSelectedCompany(ids) {
  return request({
    url: process.env.VUE_APP_BUS_SERVICE_NAME + 'api/ottTransportComp/deleteByList',
    method: 'post',
    data: {
      keyValues: ids
    }
  });
}

// 获取车辆品牌型号下拉
export function getCategoryAndTypes() {
  return request({
    url: process.env.VUE_APP_BUS_SERVICE_NAME + 'api/ottVehicleBrand/getListByPage',
    method: 'post',
    data: {
      "pageNum": 0,
      "recordNum": 0
    }
  });
}

// 获取介质类型下拉
export function getCarJZ() {
  return request({
    url: process.env.VUE_APP_SERVICE_NAME + 'api/sysEnumDictionary/getListByPage',
    method: 'post',
    data: {
      queryStr: 'ott_vehicle_info.enum_medium',
      "pageNum": 1,
      "recordNum": 200
    }
  });
}

// 获取介质类型下拉
export function getCarStatus() {
  return request({
    url: process.env.VUE_APP_SERVICE_NAME + 'api/sysEnumDictionary/getListByPage',
    method: 'post',
    data: {
      queryStr: 'ott_vehicle_info.enumTransStatus',
      "pageNum": 1,
      "recordNum": 200
    }
  });
}

// 获取运输单位下拉
export function getCompanyItems() {
  return request({
    url: process.env.VUE_APP_BUS_SERVICE_NAME + 'api/ottTransportComp/getDropDownList',
    method: 'get'
  });
}

// 获取列表
export function getCars(data) {
  return request({
    url: process.env.VUE_APP_BUS_SERVICE_NAME + 'api/ottVehicleInfo/getListByPage',
    method: 'post',
    data: data
  });
}

// 创建或者编辑
export function saveCar(data) {
  let url = process.env.VUE_APP_BUS_SERVICE_NAME + 'api/ottVehicleInfo/create';
  if (data.objectId || data.objectId == 0) {
    url = process.env.VUE_APP_BUS_SERVICE_NAME + 'api/ottVehicleInfo/update';
  }
  return request({
    url: url,
    method: 'post',
    data: data
  });
}

// 启用/停用车辆状态
export function toggleCarStatus(id, status) {
  return request({
    url: process.env.VUE_APP_BUS_SERVICE_NAME + 'api/ottVehicleInfo/enable',
    method: 'get',
    params: {
      isEnable: status,
      objectId: id
    }
  });
}

// 设置车辆关联设备
export function setDevices(data) {
  return request({
    url: process.env.VUE_APP_BUS_SERVICE_NAME + 'api/ottVehicleInfo/relatedEquipment',
    method: 'post',
    data: data
  });
}

// 获取全部报警信息
export function getAlertData(data) {
  return request({
    url: process.env.VUE_APP_BUS_SERVICE_NAME + 'api/ottAlarmInfo/getListByPage',
    method: 'post',
    data: data
  });
}

// 解除报警
export function releaseAlertApi(id) {
  return request({
    url: process.env.VUE_APP_BUS_SERVICE_NAME + 'api/ottAlarmInfo/clearAlarm',
    method: 'get',
    params: {
      objectId: id
    }
  })
}

